<report title="QIDSS Prevention Report MRP-searchable between dates" description="Prevention Report by type and date of service and by patients MRP  Prevention Status-Completed=0 Completed externally=3 Refused=1 Ineligible=2" active="1">
<query>

select distinct p.prevention_date as 'Prevention Date', p.prevention_type as 'Prevention Type', p.refused as 'Status', d.demographic_no as 'Demographic No', d.roster_status as 'Enrollment Status', d.last_name as 'Patient Last Name', d.first_name as 'Patient First Name', d.year_of_birth as ' Patient YOB',  YEAR(CURDATE()) - YEAR(concat(year_of_birth,month_of_birth,date_of_birth)) as ' Patient Age',p.creator as 'Provider # that gave the Prevention', .pr.provider_no as 'MRP #', pr.last_name as 'MRP First Name', pr.first_name as 'MRP Last Name'

from demographic d
    inner join preventions p  ON p.provider_no = d.provider_no	
    left join provider pr on p.provider_no = pr.provider_no
    left join demographicExt de on de.demographic_no=d.demographic_no

where d.demographic_no=p.demographic_no and p.prevention_type in ('{prevention_name}') and (p.prevention_date>='{service_date}') and (p.prevention_date<='{service_date2}') 
and p.provider_no={provider_no}


order by p.provider_no

</query>
